from industrialai.api import hooks
from pecan import make_app


def setup_app(config):
    app_conf = dict(config.app)
    app_hooks = [hooks.DBHook()]
    app = make_app(
        app_conf.pop('root'),
        logging=getattr(config, 'logging', {}),
        hooks=app_hooks,
        **app_conf
    )
    return app
